Skip to content

formal: add Lean proofs for KMS, gateway and guest OS logic - #1597

Open
kvinwang wants to merge 2 commits into
nextfrom
feat/lean-proofs
Open

kvinwang wants to merge 2 commits into
nextfrom
feat/lean-proofs

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Adds formal/, a Lean 4 project (core Lean, no Mathlib) with hand-written models of security-relevant logic and machine-checked proofs, plus a CI job (lean.yml) that builds it and rejects sorry, axiom and native_decide. See formal/README.md for the module list and trust base; each module header names the Rust/Solidity functions it mirrors and its modeling gaps.

  • KMS: root-epoch contract invariants and agreement with the Rust chain hashes, servable_epoch/handover binding, KDF domain separation, RA-TLS encoding injectivity, and the key-release check set.
  • Gateway: KV import, IP allocation, port policy, cert resolution, ingress parsing, health hysteresis, SNI and msgpack skipping, and the cert-renewal lock.
  • Guest: event-log preimages and replay (the V1 theorem relies on the colon check from fix(cc-eventlog): reject V1 runtime event names containing ':' #1596), the boot measure-before-use trace, MR_CONFIG_ID, instance id, env file, and compose policy checks.

Hashes and KDFs are parameters; injectivity is an explicit hypothesis, never an axiom.

Observations from the proofs, for follow-up (not changed here):

  • The cert-renewal lock is not mutually exclusive across nodes during a replication gap (documented). Its value has second granularity, so after a force release or clock step back a stale holder's release can delete a lock re-acquired in the same second.
  • extract_sni ignores the declared record/extension/server-name lengths.
  • CertStore::exact_certs is never populated, so the exact-match branch of resolve_cert is dead.
  • Cross-node instance agreement relies on node pools not overlapping, which no config check enforces; a CVM can register with node A using node B's gateway key, which A accepts and B rejects.
  • instance_id_seed length is unchecked, so the instance id alone is not globally unique across app ids (it is for a fixed app id).

Hand-written Lean 4 models of security-relevant pure logic, with
machine-checked proofs and a CI job that builds them and rejects sorry,
axioms and native_decide. Cryptographic idealizations are explicit
theorem hypotheses.

Signed-off-by: Kevin Wang <wy721@qq.com>
CertLock follows #1599-#1601 on wavekv 2.2: the lock value carries a
nonce, a lease stamped beyond the drift bound counts as expired, and
release and lease-guarded writes are no-ops once the lease expired by the
local clock. The force-release, clock-step-back and stale-release
counterexamples become positive theorems: ownership on one node under any
clock, and a release or guarded commit losing LWW to any successor whose
clock is within the drift bound. The replication gap, skew beyond the
drift bound, and cross-node force release remain as counterexamples.

Sni follows #1602: the returned name lies within every declared block.
CertStore follows #1603: no exact-match table, empty first label refused.

Signed-off-by: Kevin Wang <wy721@qq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant